package com.inexas.cu.client.pipe;

import com.google.gwt.event.shared.*;

public class ResponseEvent<R extends AbstractResponse> extends GwtEvent<ResponseHandler<R>> {
	private final R response;

	public ResponseEvent(R response) {
		this.response = response;
	}

	public R getResponse() {
		return response;
	}

	@Override
	protected void dispatch(ResponseHandler<R> handler) {
		handler.onFired(this);
	}

	@SuppressWarnings("unchecked")
	@Override
	public GwtEvent.Type<ResponseHandler<R>> getAssociatedType() {
		final Object type = response.getAssociatedType();
		return (GwtEvent.Type<ResponseHandler<R>>)type;
	}

}
